<!--# layout("/common/mallout.html"){ -->
<style>
    .cost_number{
        border: 1px solid #cccccc;
        width: 40px;
        height: 40px;
        text-align: center;
        color: #666666;
        margin-left: 10px;
        padding: 0px 10px;
    }
    .popup-content{text-align: left;}
    .fileLoadA a{text-decoration:none;color: #6647b2;display: inline-block;width: 100px;height:34px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;vertical-align: top;}
    .fileLoadI i{margin-top: 5px;;display: inline-block;width: 15px;height: 15px;cursor: pointer; margin-left: 15px; color: #f16c6c; line-height: 15px;text-align: center;}
     .the_custom_ipt{
         width: 68px;
         height: 30px;
         border: 1px solid #cccccc;
         font-weight: 200;
     }
</style>
<link rel="stylesheet" href="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fstyle%2Fproduct.css">
<div id="hiddenParam">
    <input type="hidden" id="hiddenGoodsId" value="${goodsId}">
    <input type="hidden" id="hiddenGoodsType" value="${goodsType}">
    <input type="hidden" id="designData" value="">
    <input type="hidden" id="append" value="">
    <input type="hidden" id="fileNum" value="">
</div>
<div id="detail"></div>

<div class="breadcrumb">
    <div class="bread-crumbs">
        <div class="bread_left">
            <div class="bread-crumbs">
        	<span id="indexHtml">
				<a href="/index.do">首页</a>
			</span>

                <script type="text/html" id="category">
                    {{ each categoryMap category key}}
                    <span class="arrows">»</span>
                    <span class="now"><a href="/mall/category.do?categoryId={{key}}">{{category}}</a>
                                </span>
                    {{ /each }}
                    <input type="hidden" class="parameter" id="shopId" value="{{sellerDetail['merchantId']}}">
                    <input type="hidden" class="parameter" id="goodsType" value="{{goodsType}}">

                    <input type="hidden" class="parameter" id="spuId" value="{{spu}}">

                    <span id="designParam" trussSkuId="" urgent="" trussNum="" goodsType="design" designDesc=""></span>
                </script>

            </div>
        </div>
    </div>
</div>
<!-------------------------------------->
<div id="defindHtml" style="display:none;">
    <input type="hidden" specvalueid="" id="designUrgentVal">
    <div id="designAppendHtml"></div>

    <div id="materialHtml" flag = 0></div>
    <input type="hidden" id="materialWidth"  value="">
    <input type="hidden" id="materialLength"  value="">

<div class="paper">
<input id="paperInput" type="text" value="0"><!--0平板 1卷筒-->
</div>
<div class="paperReam">
<input type="text" id="reamChooseId" specvalueid="" widthValue="787" lengthValue="1092" lprice="" dprice="" zprice="">
<input type="text" id="reamSizeId" specvalueid="-0" widthValue="787" lengthValue="1092" >
</div>
<div class="paperTon">
<input type="text" id="tonChooseId" specvalueid="" widthValue="787" dprice="" zprice="">
<input type="text" id="tonSizeId" specvalueid="-0" widthValue="787">
</div>
</div>

<div class="center">
    <div class="section" id="center">
<!-- 商品详情 -->
        <div class="page-maincontent">
            <div class="product-side product-img" id="leftHtml">
                <!--默认适配地图-->
                    <div class="product-album-preview">
                        <img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_04.png">
                    </div>
            </div>

            <div class="product-titles titles">
                    <h2>名片</h2>
                    <p></p>
            </div>

            <div id="rightHtml">
                <!--默认适配地图-->
                                    <div class="product-spec-box" id="rightHtml">
                                        <!--------------工艺参数-------------------------->
                                        <div class="product-spec-price-shipping product-buy">
                                            <span partid="13814" class="partParam">
                                            <div class="product-spec-price-box AttributeOptionDto">
                                               <span class="item-label" optionid="13" attributetype="normal" attributekey="" influencecraftpricetype="">产品尺寸:</span>
                                                <div class="item-content">
                                                    <span class="spec-attr atver  normal  " specvalueid="85">90x54mm(常规尺寸)<em></em></span>
                                                </div>
                                            </div>
                                            </span>
                                            <div class="product-spec-price-box" style="margin-top: 0px">
                                                <span class="item-label">购买数量:</span>
                                                <div class="item-content">
                                                    <em class="input_box">
                                                        <a href="javascript:void(0);" class="btn-increase">+</a>
                                                        <input onkeydown="if(event.keyCode==13)return false;" type="text" name="goods[num]" class="action-quantity-input" value="1" min="1" max="99999">
                                                        <a href="javascript:void(0);" class="btn-decrease">-</a>
                                                    </em>
                                                </div>
                                            </div>
                                            <div class="product-spec-price-box">
                                                <span class="item-label">运费:</span>
                                                <div class="item-content">
                                                    <span class="spec-attr-text freightPrice">￥<strong>0 </strong> 预估重量 0kg</span>
                                                </div>
                                            </div>
                                            <div class="product-spec-price-box">
                                                <span class="item-label">单价:</span>
                                                <div class="item-content">
                                                    <span class="spec-attr-text singlePrice">￥<strong>11.00/盒</strong></span>
                                                </div>
                                            </div>
                                            <div class="product-spec-price-box">
                                                <span class="item-label">总价:</span>
                                                <div class="item-content">
                                                    <span class="spec-attr-text totalPrice"><font>￥<strong>10</strong></font>元</span>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
            </div>

                <div class="product-spec-price-box" style="float: right;margin-top: 10px;">
                    <span class="item-label" style="padding-right: 6px;">区域选择:</span>
                    <div class="item-content">
                             <span class="spec-attr address_text">
                            	<a href="javascript:void(0)">湖北 武汉市 江汉区</a><s></s>
                                <div class="address_select">
                                    <div class="address_tab">
                                        <span class="atver"><i>湖北</i></span>
                                        <span><i>武汉</i></span>
                                        <span><i>江汉区</i></span>
                                    </div>
                                    <div style="display:none;">
                                        <select class="address_op"></select>
                                        <select class="address_op"></select>
                                        <select class="address_op"></select>
                                    </div>
                                    <div class="address_con">

                                    </div>
                                    <div class="address_con">

                                    </div>
                                    <div class="address_con">

                                    </div>
                                </div>
                             </span>
                    </div>
                </div>
                <div class="product-spec-price-box" style="float: right;margin-top: 10px;margin-bottom: -5px;">
                    <span class="item-label"></span>
                    <div class="item-content" style="margin-top: 5px;">
                        <span style="height: 30px;padding-left: 14px;box-sizing: border-box;display: inline-block;width: 450px;background:#f1eefa;line-height: 30px;color: #333;margin-left: 10px;">此商品由 <a href=" javascript:void(0) " class="red_price merchantName"></a> 发货, 并提供售后服务.</span><br>
                        <span style="height: 30px;padding-left: 14px;box-sizing: border-box;display: inline-block;width: 450px;background:#f1eefa;line-height: 30px;color: #333;margin-left: 10px;">此门店电话为：<a class="red_price mobile"></a></span>
                    </div>
                </div>
                <!----------参数分类  模块end----------------->
                <div class="product-spec-price-box  operationButtonDiv" >
                    <span class="item-label" ></span>
                    <div class="item-content operationButton" style="float: right">
                        <button type="submit" class="action-addtocart" id="buynow">立即购买</button>
                        <button type="submit" class="action-addtocart" id="addcart">加入购物车</button>
                    </div>
                </div>
                <div class="product-spec-price-box" style="float: right" id="canUploadFile">
                    <span class="item-label">附件:</span>
                    <div class="item-content" style="vertical-align:inherit">
                        <div class="action-uploadFile" id="uploadFile">上传附件</div>
                        <span style="position: relative;margin-left: 15px;top: 35px">
                            <span class="file_info_list picture" style="position: absolute;left: 0px;right: 0px ;height: 30px; width: 185px; display: inline-block; vertical-align: middle;padding: 2px;overflow: hidden">
                            </span>
                        </span>
                        <span style="margin-left: 180px;cursor: pointer;display: none" class="moreFile">更多</span>
                    </div>
                </div>
            </div>

            <!----------右侧---------->

            <div style="clear: both;"></div>
        <!-------------------图文详情-------------------------------->
        <div class="product_section">
            <div class="product_detail">
                <div class="product-attributes">
                    <span class="atver" name="productDetail">商品详情</span>
                    <span name="afterService">售后服务</span>
                </div>
                <div id="lastDetail"></div>

                <script type="text/html" id="scriptDetail">
                    <div class="detail-content" id="productDetail" style="display: block;">
                        <div class="detail-content-title">商品详情</div>
                        <div class="detail_argument">
                            <!---------详情填充-------->
                            {{if detailInfo.length <1}}
                            <div style="text-align:center;">
                                <img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_04.png">
                            </div>
                            {{else}}
                            {{each detailInfo as detail}}
                            <div style="text-align:center;">
                                <img src="${imagepath}/{{detail}}">
                            </div>
                            {{/each}}
                            {{/if}}
                        </div>
                    </div>
                    <div class="detail-content" id="afterService" style="display: none;">
                        <div class="detail-content-title">售后服务</div>
                        <div class="detail_argument">
                            <!---------详情填充-------->
                            <div style="text-align:center;">
                                {{productDesc}}
                            </div>
                        </div>
                    </div>
                </script>

            </div>
        </div>

    </div>

    <!-------------------------------------->
    </div>


<script type="text/html" id="left">
    <!----------左侧----------->

    <div class="product-album-preview">
        {{if goodsInfoDetail['defaultImage'] != null}}
        <img src="${imagepath}/{{goodsInfoDetail['defaultImage']}}">
        {{else}}
        <img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_02.png">
        {{/if}}
    </div>
    <div class="product-album-thumb">
        <span class="flip_prev flip"></span>
        <div class="thumbnail-list">
            <ul>
                {{each goodsInfoDetail['imageUrls'] url}}
                <li>
                    <a href="javascript:">
                        <img src="${imagepath}/{{url}}">
                    </a>
                </li>

                {{/each}}
            </ul>
        </div>
        <span class="flip_next flip"></span>
    </div>
    <!-- 分享推荐收藏 -->
</script>
<script type="text/html" id="titles">
    <h2>{{spuName}}</h2>
    <p>{{goodsInfoDetail['brief']}}</p>
</script>
<script type="text/html" id="right">
    <div class="product-spec-box" id="rightHtml">

        <div class="product-titles">
            <!--------------页面影藏参数-------------------------->

            <input type="hidden" class="parameter" id="templetId" value="{{freightTemplateId}}">
            <input type="hidden" class="parameter" id="id" value="{{basePriceDetail['productId']}}">
            <input type="hidden" class="parameter" id="isNoStoreSell" value="{{isNoStoreSell}}">
            <input type="hidden" class="parameter" id="store" value="{{store}}">
        </div>

        <!--------------工艺参数-------------------------->
        <div class="product-spec-price-shipping product-buy">
            <!-----------参数分类  标品 ----------->


            {{if goodsType == 'standard' || goodsType == 'copy' || goodsType == 'material'}}

            {{each partAttrOptionList as part}}

            <span partId="{{part['partId']}}" class="partParam">

                 {{each part['attrOptionListsInfoList'] as attr }}

                 {{if attr['attrSquare']['attributeType'] != 'design' }}

                    <div class="product-spec-price-box AttributeOptionDto">
                        {{else}}
                    <div class="product-spec-price-box designDto">
                        {{/if}}

                        {{if attr['attrSquare']['attributeType'] == 'craft'}}
                        <span class="item-label" optionId="{{attr['attrSquare']['id']}}" attributeType="{{attr['attrSquare']['attributeType']}}" attributeKey="{{attr['attrSquare']['attributeKey']}}" influenceCraftPriceType="{{attr['attrSquare']['influenceCraftPriceType']}}" joinBuildSku="{{attr['attrSquare']['joinBuildSku']}}">{{attr['attrSquare']['squareName']}}:</span>
                        <div class="item-content">
                            {{each attr['optionDTO'] option}}
                            <span class="spec-attr craft {{option['defaultOption'] == true ? 'atver':''}} {{attr['attrSquare']['joinBuildSku'] == true? 'must':''}}   " specvalueid="{{option['id']}}" >{{option['squareName']}}<em></em></span>
                            {{/each}}
                        </div>

                        {{else if attr['attrSquare']['attributeType'] == 'design'}}

                        <span class="item-label" optionId="{{attr['attrSquare']['id']}}" attributeType="{{attr['attrSquare']['attributeType']}}" attributeKey="{{attr['attrSquare']['attributeKey']}}" influenceCraftPriceType="{{attr['attrSquare']['influenceCraftPriceType']}}">{{attr['attrSquare']['squareName']}}:</span>
                        <div class="item-content ">
                            <span class="spec-attr design atver " specvalueid="0" >不需要<em></em></span>
                            <span class="spec-attr design" specvalueid="1" >需要<em></em></span>
                        </div>

                        {{else}}
                       <span class="item-label" optionId="{{attr['attrSquare']['id']}}" attributeType="{{attr['attrSquare']['attributeType']}}" attributeKey="{{attr['attrSquare']['attributeKey']}}"  >{{attr['attrSquare']['squareName']}}:</span>
                        <div class="item-content">
                            {{each attr['optionDTO'] option }}
                            <span class="spec-attr {{option['defaultOption']== true ? 'atver':''}}   {{attr['attrSquare']['attributeType']}}"    attributeKey="{{attr['attrSquare']['attributeKey']}}"  specvalueid="{{option['id']}}"  optionValue = "{{option['optionValue']}}">{{option['squareName']}}<em></em></span>
                            {{/each}}

                            {{if attr['attrSquare']['customMade'] == true}}
                                 <p class="item-con defindArea" optionid="{{attr['attrSquare']['id']}}" >
                                    <span class="the_custom "  id="{{attr['attrSquare']['id']}}" val="{{attr['attrSquare']['customLimitValue']}}" attributeValueType="{{attr['attrSquare']['attributeKey']}}"><em></em>自定义</span>
                                    <span class="defInput"  id="material_{{attr['attrSquare']['id']}}"  parentId="{{part['partId']}}" defId="{{attr['attrSquare']['id']}}" attributeValueType="{{attr['attrSquare']['attributeKey']}}"></span>
                                </p>
                                {{/if}}

                        </div>


                        {{/if}}

                    </div>
                        {{/each}}

               </span>
            {{/each}}

            {{/if}}


            {{if goodsType == 'design'}}

            {{each partAttrOptionList as part}}
            <span partId="{{part['partId']}}" class="partParam">
                    {{each part['attrOptionListsInfoList'] as attr }}
                    <div class="product-spec-price-box AttributeOptionDto">
                        <span class="item-label" optionId="{{attr['attrSquare']['id']}}" attributeType="{{attr['attrSquare']['attributeType']}}" attributeKey="{{attr['attrSquare']['attributeKey']}}" influenceCraftPriceType="{{attr['attrSquare']['influenceCraftPriceType']}}" joinBuildSku="{{attr['attrSquare']['joinBuildSku']}}">{{attr['attrSquare']['squareName']}}:</span>
                        <div class="item-content">
                            {{each attr['optionDTO'] option}}
                            <span class="spec-attr  {{option['defaultOption'] == true ? 'atver':''}} {{attr['attrSquare']['joinBuildSku'] == true? 'must':''}}  normal"  specvalueid="{{option['id']}}" >{{option['squareName']}}<em></em></span>
                            {{/each}}
                        </div>
                    </div>
                        <div class="product-spec-price-box">
                            <span class="item-label">加急</span>
                        <div class="item-content ">
                            <span class="spec-attr designUrgent atver exclud" specvalueid="-99" price="0">不加急<em></em></span>
                            <span class="spec-attr designQuick exclud" specvalueid="-9" price="{{ basePriceDetail['totalPrice']/2 }}">加急<em></em></span>
                        </div>
                            <span class="item-label">*需求描述</span>
                            <div class="item-content">
                                <textarea placeholder="需求描述" id="designDesc" maxlength="240"></textarea>
                            </div>
                        </div>

                    {{/each}}
                    </span>
            {{/each}}
            {{/if}}


            <!-----------参数分类  大纸 ----------->
            {{if goodsType == 'paper'}}
            <div class="product-big-page">
                <div class="product-big-title">
                    {{if basePriceDetail['expandPrice'] !=null &&  basePriceDetail['expandPrice']!=0}}
                    <span class="paper atver" unit="ream" >平板</span>
                    <span class="paper " unit="ton" style="width: {{basePriceDetail['expandPrice']==null? '498px' : '248px'}};">卷筒</span>
                    {{else}}
                    <span class="paper atver" unit="ton" style="width:498px;">卷筒</span>
                    {{/if}}
                </div>

                <div class="product-big-con">
                    <input type="hidden" {{ping = 0 }} {{optionLen = 0 }} {{optionWid = 0 }} >
                    {{if basePriceDetail['expandPrice'] !=null && basePriceDetail['expandPrice']!=0}}
                    <input type="hidden" {{ping = 1 }} >
                    {{/if}}

                    <!--**********************包含平板**********************-->
                    {{each partAttrOptionList partAttr}}

                    <span partId="{{partAttr['partId']}}" class="partParam">
                            <ul style="display:{{ping == 1 ?'block':'none'}};" class="ream">
                                {{each partAttr['attrOptionListsInfoList'] attrList}}

                                    <li class="AttributeOptionDto">

                                        <span optionId="{{attrList['attrSquare']['id']}}" attributeType="{{attrList['attrSquare']['attributeType']}}" attributeKey="{{attrList['attrSquare']['attributeKey']}}" influenceCraftPriceType="{{attrList['attrSquare']['influenceCraftPriceType']}}">{{attrList['attrSquare']['squareName']}}:</span>
                                        <p>
                                            {{each attrList['optionDTO'] dto }}
                                            <span class="spec-attr {{dto['defaultOption']== true ? 'atver':''}}  {{attrList['attrSquare']['attributeType']}}  " specvalueid="{{dto['id']}}" >{{dto['squareName']}}<em></em></span>
                                            {{/each}}
                                        </p>
                                    </li>

                                    <li>
                                        <label>规格:</label>
                                        <p>
                                            <span class="spec-attr paper_spec" specvalueid="-0"  optionWid="787" optionLen="1092" >正度（787-1092）<em></em></span>
                                            <span class="spec-attr paper_spec "  specvalueid="-1" optionWid="889" optionLen="1194" >大度（889-1194）<em></em></span>
                                            <span class="spec-attr paper_spec" specvalueid="-2" very="-1">特规<em></em></span>
                                        </p>
                                    </li>
                                        <li class="product-big-unusual">
                                            <label>宽度</label>
                                            <input type="text"  placeholder="请填写" class="width drules" readonly value="787" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/"><label>mm</label>
                                            <label>长度</label>
                                            <input type="text" placeholder="请填写" class="length drules" readonly value="1092" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/"><label>mm</label>
                                        </li>

                                {{/each}}
                            </ul>


                        <!--**********************包含卷筒**********************-->

                            <ul style="display:{{ping==1?'none':'block'}};" class="ton">
                                {{each partAttr['attrOptionListsInfoList'] attrList }}
                                <li class="AttributeOptionDto">
                                    <span optionId="{{attrList['attrSquare']['id']}}" attributeType="{{attrList['attrSquare']['attributeType']}}" attributeKey="{{attrList['attrSquare']['attributeKey']}}" influenceCraftPriceType="{{attrList['attrSquare']['influenceCraftPriceType']}}">{{attrList['attrSquare']['squareName']}}:</span>
                                    <p>
                                        {{each attrList['optionDTO'] dto}}
                                        <span class="spec-attr {{dto['defaultOption']== true ? 'atver':''}} {{attrList['attrSquare']['attributeType']}}   " specvalueid="{{dto['id']}}" >{{dto['squareName']}}<em></em></span>
                                        {{/each}}
                                    </p>
                                </li>

                                <li>
                                    <label >常见宽度:</label>
                                    <p>
                                        <span class="spec-attr paper_spec ton" specvalueid="-0" optionWid="787" >787<em></em></span>
                                        <span class="spec-attr paper_spec ton" specvalueid="-1" optionWid="889" >889<em></em></span>
                                        <span class="spec-attr paper_spec" specvalueid="-2" very="-1">特规<em></em></span>
                                    </p>
                                </li>
                                <li class="product-big-unusual">
                                    <label>宽度</label>
                                    <input type="text"  placeholder="请填写" readonly class="width flagLength drules"  value="787" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/"><label> mm</label>
                                    <!--<input type="hidden" class="hidInput"  readonly   value="0" />-->
                                </li>


                                {{/each}}
                            </ul>
                            </span>
                    {{/each}}
                </div>
            </div>
            {{/if}}

            <!-----------参数分类  模块----------->
            <div class="product-spec-price-box" style="margin-top: {{ goodsType == 'paper' ? '25px' : '0px'}}">
                <span class="item-label">购买数量:</span>
                <div class="item-content">
                    <em class="input_box">
                        <a href="javascript:void(0);" class="btn-increase">+</a>
                        <input onkeydown="if(event.keyCode==13)return false;" type="text" name="goods[num]" class="action-quantity-input" minBuy="{{minBuy}}" value="{{buyCount}}" min="1" max="99999">
                        <a href="javascript:void(0);" class="btn-decrease">-</a>
                    </em>
                </div>
            </div>

            {{if goodsType == 'paper'}}
            <div class="product-spec-price-box ream"  style="display:{{basePriceDetail['plateLPrice'] == null ? 'none': 'block'}}">
                <span class="item-label">令价:</span>
                <div class="item-content">
                    <span class="spec-attr-text plateLPrice otherPriceSpan" >￥<strong>{{basePriceDetail['plateLPrice']}}</strong></span>
                </div>
            </div>

            <div class="product-spec-price-box ream" style="display:{{basePriceDetail['plateLPrice'] == null ? 'none': 'block'}}">
                <span class="item-label">吨价:</span>
                <div class="item-content">
                    <span class="spec-attr-text reamTonPrice otherPriceSpan">￥<strong>{{basePriceDetail['expandPrice']}}</strong></span>
                </div>
            </div>

            <div class="product-spec-price-box ream" style="display:{{basePriceDetail['plateLPrice'] == null ? 'none': 'block'}}">
                <span class="item-label">总价:</span>
                <div class="item-content">
                    <span class="spec-attr-text reamTotalPrice totalPriceSpan"><font>￥<strong>{{basePriceDetail['totalPrice']}}</strong></font>元</span>
                </div>
            </div>

            <div class="product-spec-price-box ton" style="display: {{basePriceDetail['plateLPrice'] != null ? 'none': 'block'}}">
                <span class="item-label">吨价:</span>
                <div class="item-content">
                    <span class="spec-attr-text tonTonPrice otherPriceSpan">￥<strong>{{ basePriceDetail['coilingTonPrice']}}</strong></span>
                </div>
            </div>

            <div class="product-spec-price-box ton" style="display:{{basePriceDetail['plateLPrice'] != null ? 'none': 'block'}}">
                <span class="item-label">总价:</span>
                <div class="item-content">
                    <span class="spec-attr-text tonTotalPrice totalPriceSpan"><font>￥<strong>{{basePriceDetail['totalPrice']}}</strong></font> 元</span>
                </div>
            </div>

            {{else}}

            <div class="product-spec-price-box">
                <span class="item-label">运费:</span>
                <div class="item-content">
                    <span class="spec-attr-text freightPrice otherPriceSpan">￥<strong>{{basePriceDetail['freightPrice']}} </strong> 预估重量 {{weight}}/kg</span>
                </div>
            </div>

            <div class="product-spec-price-box">
                <span class="item-label">单价:</span>
                <div class="item-content">
                    <span class="spec-attr-text singlePrice otherPriceSpan">￥<strong>{{ goodsType != 'copy' ? basePriceDetail['singlePrice'] : basePriceDetail['expandPrice'] }}</strong></span>
                </div>
            </div>
            <div class="product-spec-price-box" >
                <span class="item-label">总价:</span>
                <div class="item-content">
                    <span class="spec-attr-text totalPrice totalPriceSpan"><font>￥<strong>{{basePriceDetail['rangePrice'] !=null? basePriceDetail['rangePrice']: basePriceDetail['totalPrice']}}</strong></font> 元</span>
                    {{if goodsType == 'design'}}
                    <span class="spec-attr-text quickPrice otherPriceSpan" style="padding-top: 3px;"><font>加急费用<b id="quickPrice">0.0</b></font>元</span>
                    {{/if}}
                </div>
            </div>

            {{/if}}

        </div>

    </div>
    <!----------------->
    </div>
</script>
<script src="http://www.11ziyun.com/js/region.js"></script>
<!--#} -->

<script>

doAjax("/mall/standradDetails.json","post",{"goodsId":$("input#hiddenGoodsId").val(),"goodsType":$("input#hiddenGoodsType").val()},function (ret) {
    if(ret.code != 1){
        //如果报错 没有商品
        $("div.center").html('');
        var goods = "<div style=\"height:320px; background:url('https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_04.png') center center no-repeat; text-align:center;  font-size:22px; color:rgb(208,208,208);overflow:hidden;\"><p style=\"margin-top:250px;\">暂无该商品呢,亲</p></div>";

        $("div.center").html(goods);
        return;
    }
    //左边不变，分类不变，spu 商户信息 数量  地址
    var left = template('left', ret.data);
    var right = template('right', ret.data);
    var category = template('category', ret.data);
    var titles = template('titles',ret.data);
    var lastDetail = template("scriptDetail",ret.data.goodsInfoDetail);
    $("span#indexHtml").append(category);
    $("div#leftHtml").html(left);
    $("div#rightHtml").html(right);
    $("div.titles").html(titles);
    $("#lastDetail").html(lastDetail);
    $(".merchantName").html(ret.data.sellerDetail.merchantName);
    $(".merchantName").attr("href","/mall/providerDetail.do?sellerId="+ret.data.sellerDetail.merchantId);
    $(".mobile").html(ret.data.sellerDetail.mobile);
    var design = ret.data.partAttrOptionList[0].attrOptionListsInfoList;

    for(var i=0,l=design.length;i<l;i++){
        if(design[i].attrSquare.attributeType == 'design'){
            $("#designData").val( JSON.stringify(design[i]));
        }
    }

    if(ret.data.goodsType == 'paper'){
        var tonId = $("ul.ton").children("li.AttributeOptionDto").find("span.atver").attr("specvalueid");
        var reamId = $("ul.ream").children("li.AttributeOptionDto").find("span.atver").attr("specvalueid");
        $("#defindHtml").children("div.paperReam").find("input#reamChooseId").attr('lprice',ret.data.basePriceDetail.plateLPrice);
        $("#defindHtml").children("div.paperReam").find("input#reamChooseId").attr('dprice',ret.data.basePriceDetail.expandPrice);
        $("#defindHtml").children("div.paperReam").find("input#reamChooseId").attr('zprice',ret.data.basePriceDetail.totalPrice);
        $("#defindHtml").children("div.paperTon").find("input#tonChooseId").attr('dprice',ret.data.basePriceDetail.coilingTonPrice);
        $("#defindHtml").children("div.paperTon").find("input#tonChooseId").attr('zprice',ret.data.basePriceDetail.coilingTonPrice);
        $("#defindHtml").children("div.paperReam").find("input#reamChooseId").attr("specvalueid",reamId)
        $("#defindHtml").children("div.paperTon").find("input#tonChooseId").attr("specvalueid",tonId);

        $("ul.ream").find("span.paper_spec").eq(0).addClass("atver");
        $("ul.ton").find("span.paper_spec").eq(0).addClass("atver");
        $("div#defindHtml").children("div").find("input#paperInput").val(ret.data.basePriceDetail.plateLPrice == null? 1:0);
    }



    if(ret.data.canUploadFile == true){
        $("#canUploadFile").show();
    }else{
        $("#canUploadFile").hide();
    }
    //商品已经下架

    if(ret.data.marketable == 'pulloff' || ret.data.marketable == 'nostore'){
        $("div.operationButton").html("<button  style='background: #ddd' class='action-addtocart nosale' >商品暂不销售</button>");
        $("#canUploadFile").hide();
    }

});



//组装参数发送ajax请求

function installParam() {

    var goodsParamsVO = {};
    var goodsType = $('#goodsType').val();

    var attrRelateOptList = attributeOptionNames();


    if(goodsType == 'paper'){
        var flag = true;
        $("input.drules:visible").each(function () {
            if( $(this).val() == '' ){
                flag = false;
            }
        });
        if(!flag){
            $.alert("error","大纸规格请填写完整",1);
            return ;
        }

        var width = $(".width:visible").val();
        var length = $(".length:visible").val();
        if(!length){
            length = null;
        }
        goodsParamsVO['paperWidth'] = width;
        goodsParamsVO['paperLength'] = length;

        if($("div#defindHtml").children("div").find("input#paperInput").val() == 1){
            $("#defindHtml").children("div.paperTon").find("input#tonSizeId").attr('widthValue',width);
            $("#defindHtml").children("div.paperTon").find("input#tonSizeId").attr('lengthValue',length);
        }else{
            $("#defindHtml").children("div.paperReam").find("input#reamSizeId").attr('widthValue',width);
            $("#defindHtml").children("div.paperReam").find("input#reamSizeId").attr('lengthValue',length);
        }
        goodsParamsVO['priceUnit'] = $(".product-big-title").find(".paper.atver").attr('unit');

    }else if(goodsType == 'material'){
        var flag = true;
        $("input.zdy:visible").each(function () {
            if( $(this).val() == '' ){
                flag = false;
            }
        });
        if(!flag){
            $.alert("error","自定义尺寸请填写完整",1);
            return ;
        }

        if($("#materialHtml").attr('flag') == 1){ //说明 自定义 则传入自定义的值
            goodsParamsVO['paperLength'] = $("input.zdy:visible").eq(0).val();
            goodsParamsVO['paperWidth'] = $("input.zdy:visible").eq(1).val();
        }else{
            goodsParamsVO['paperLength'] = $("#materialLength").val();
            goodsParamsVO['paperWidth'] = $("#materialWidth").val();
        }
    }

    $("input[type=hidden].parameter").each(function () {
        var name = $(this).attr('id');
        var value = $(this).val();
        if(name=='spuId'){
            goodsParamsVO['goodsId'] = value;
        }else{
            goodsParamsVO[name] = value;
        }
    });
    goodsParamsVO['quantity'] = $("input.action-quantity-input").val();//组装数量
    goodsParamsVO['areaId'] = $(".input_addr").val();
    goodsParamsVO['partAndAttrRelateOptListMap'] = attrRelateOptList;

    var store = Number($('#store').val());
    var isNoStoreSell = $("#isNoStoreSell").val();
    if(Number($("input.action-quantity-input").val())>store){
        if(isNoStoreSell == "false"){
            $("input.action-quantity-input").val(store);
            goodsParamsVO['quantity'] = store;
            $(".action-quantity-input").val(store);
             $.alert("error","当前数量超过库存",1);
            // return;
        }
    }

    var url = "/goods/getSellPrice.json";
    var paramsVO = JSON.stringify(goodsParamsVO);
    var list = JSON.stringify(attrRelateOptList);
    doAjax(url,'post',{"goodsParamsVO":paramsVO/*,"attrRelateOptList":list*/},function (ret) {
        $("div.operationButton").find("button").css("background","").removeClass("nosale");
        $("div.operationButton").html("<button type=\"submit\" class=\"action-addtocart\" id=\"buynow\">立即购买</button>\n" +
            "                        <button type=\"submit\" class=\"action-addtocart\" id=\"addcart\">加入购物车</button>");
        $("#canUploadFile").show();
        if(ret.code=='1'){

            if(ret.data.marketable == 'pulloff' || ret.data.marketable == 'nostore'){
                $("div.operationButton").html("<button  style='background: #ddd' class='action-addtocart nosale' >商品暂不销售</button>");
                $("#canUploadFile").hide();
            }

            var html = template('right', ret.data);
            $("div#rightHtml").html('');
            $("div#rightHtml").html(html);

            if($("#designParam").attr('trussSkuId')){
                $("span.design[specvalueid=1]").after('');
                $("span.design[specvalueid=1]").addClass("atver").siblings().removeClass("atver");
                var designHtml = $("div#defindHtml").find("div#designAppendHtml").html();//将自定义的元素保存
                $("span.design[specvalueid=1]").after(designHtml);
            }
            if(goodsType == 'paper'){
                if($("div#defindHtml").children("div").find("input#paperInput").val() == 1){ //卷筒
                    $("div.product-big-title").find("span[unit=ton]").addClass("atver").siblings("span").removeClass("atver");
                    $("ul.ream").hide();
                    $("ul.ton").show();
                    // $("div.ream").hide();
                    // $("div.ton").show();
                    //选中和设置
                    var obj = $("div#defindHtml").children("div.paperTon").find("input#tonSizeId");

                    $("ul:visible").find("span.paper_spec").each(function () {
                        if($(this).attr("specvalueid") == obj.attr("specvalueid")){
                            $(this).addClass("atver").siblings().removeClass("atver");
                        }
                    });
                    if(obj.attr('specvalueid') == -2){
                        $("input.width").prop('readonly',false);
                        $("input.length").prop('readonly',false);
                    }
                    $("input.width").val(obj.attr('widthValue'));
                }else{  //平板
                    $("div.product-big-title").find("span[unit=ream]").addClass("atver").siblings("span").removeClass("atver");
                    $("ul.ream").show();
                    $("ul.ton").hide();
                    // $("div.ream").show();
                    // $("div.ton").hide();

                    //选中和设置
                    var obj = $("div#defindHtml").children("div.paperReam").find("input#reamSizeId");

                    $("ul:visible").find("span.paper_spec").each(function () {
                        if($(this).attr("specvalueid") == obj.attr("specvalueid")){
                            $(this).addClass("atver").siblings().removeClass("atver");
                        }
                    });
                    if(obj.attr('specvalueid') == -2){
                        $("input.width").prop('readonly',false);
                        $("input.length").prop('readonly',false);
                    }
                    $("input.width").val(obj.attr('widthValue'));
                    $("input.length ").val(obj.attr('lengthValue'));
                }
            }else if(goodsType == 'design'){
                var specvalueid = $("input#designUrgentVal").attr('specvalueid');
                if(specvalueid){
                    $("span.exclud[specvalueid="+specvalueid+"]").addClass("atver").siblings().removeClass("atver");
                    if($("span.exclud[specvalueid="+specvalueid+"]").hasClass("designUrgent")){ //如果不加急，
                        $("span.totalPrice").find("strong").text( Number($("span.totalPrice").find("strong").text()) - Number($("#quickPrice").text()));
                        $("#quickPrice").text('0.0');
                        $("input#designUrgentVal").attr("specvalueid",$(this).attr("specvalueid"));
                    }else if($("span.exclud[specvalueid="+specvalueid+"]").hasClass("designQuick")){
                        $("#quickPrice").text($("span.exclud[specvalueid="+specvalueid+"]").attr("price"));
                        $("span.totalPrice").find("strong").text( Number($("span.totalPrice").find("strong").text()) + Number($("span.exclud[specvalueid="+specvalueid+"]").attr('price')));
                        $("input#designUrgentVal").attr("specvalueid",$(this).attr("specvalueid"));
                    }
                }
            }else if(goodsType == 'material'){
                if($("#materialHtml").attr('flag') == 1){ //将数据回显到页面
                    $("span.the_custom").addClass("atv");
                    var type = $("#materialHtml").attr("attributevaluetype");
                    $("span.defInput[attributevaluetype="+type+"]").html($("#materialHtml").html());
                }

            }
        }else if(ret.code == '1317'){  //暂不销售
                $("span.otherPriceSpan").html(0);
                $("span.totalPriceSpan").html(ret.message).css("font-size","20px").css("color","red");
                //控制下单按钮
                $("div.operationButton").find("button").css("background","#ddd").addClass("nosale");

        }else{
            $.alert("error",ret.message,1);
        }
    });
}


///**************************************************************************************

//监听尺寸输入框变化

$(document).on("change","input.length,input.flagLength",function () {
    installParam();
});

//大纸变换平板，卷筒
$(document).on('click',".product-big-title .paper",function () {
        if($(this).hasClass('atver'))
        {
            return;
        }
        if($(".product-big-title .paper").length>1)
        {
            if($(this).attr('unit') == 'ton'){
                $("div#defindHtml").children("div").find("input#paperInput").val(1); //卷筒
                $("ul.ream").hide();
                $("ul.ton").show();
                $("div.ream").hide();
                $("div.ton").show();

                //选中和设置
                var obj = $("div#defindHtml").children("div.paperTon").find("input#tonSizeId");

                var specvalueid = $("div#defindHtml").children("div.paperTon").find("input#tonChooseId").attr('specvalueid');
                $(".AttributeOptionDto:visible").find("span[specvalueid="+specvalueid+"]").addClass("atver").siblings().removeClass("atver");

                $("ul:visible").find("span.paper_spec").each(function () {
                    if($(this).attr("specvalueid") == obj.attr("specvalueid")){
                        $(this).addClass("atver").siblings().removeClass("atver");
                    }
                });
                if(obj.attr('specvalueid') == -2){
                    $("input.width").prop('readonly',false);
                    $("input.length").prop('readonly',false);
                }
                $("input.width").val(obj.attr('widthValue'));


            }else{
                $("div#defindHtml").children("div").find("input#paperInput").val(0);//平板
                $("ul.ream").show();
                $("ul.ton").hide();
                $("div.ream").show();
                $("div.ton").hide();
//选中和设置

                var specvalueid = $("div#defindHtml").children("div.paperReam").find("input#reamChooseId").attr('specvalueid');
                $(".AttributeOptionDto:visible").find("span[specvalueid="+specvalueid+"]").addClass("atver").siblings().removeClass("atver");

                var obj = $("div#defindHtml").children("div.paperReam").find("input#reamSizeId");

                $("ul:visible").find("span.paper_spec").each(function () {
                    if($(this).attr("specvalueid") == obj.attr("specvalueid")){
                        $(this).addClass("atver").siblings().removeClass("atver");
                    }
                });
                if(obj.attr('specvalueid') == -2){
                    $("input.width").prop('readonly',false);
                    $("input.length").prop('readonly',false);
                }
                $("input.width").val(obj.attr('widthValue'));
                $("input.length ").val(obj.attr('lengthValue'));

            }

            $(this).addClass('atver').siblings().removeClass('atver');

            installParam();
        }
});


$(document).on('click','.product-buy .item-content .spec-attr, .product-big-con ul li .spec-attr',function(){
    //点击切换样式
    // if($(this).hasClass("mutual")){
    //     return;
    // }
    if($(this).attr('specvalueid')){
        //判断是否是设计产品
        if($(this).hasClass('design') && $(this).attr('specvalueid') == 1){
            $(this).addClass('atver').siblings().removeClass('atver');
            designSendParam();
            return;
        }else if($(this).hasClass('design') && $(this).attr('specvalueid') == 0){
            $("div#defindHtml").find("div#designAppendHtml").html('');
            $("span.design[specvalueid=1]").next().remove();
            $(this).addClass('atver').siblings().removeClass('atver');
            $("#designParam").attr("trussSkuId",'');
            $("#designParam").attr("urgent",'');
            $("#designParam").attr("trussNum",'');
            return;
        }

        if(!$(this).hasClass('atver')){
            $(this).addClass('atver').siblings().removeClass('atver');
            //判断是大纸
            if($("#goodsType").val() == 'paper'){
                var unit = $("div.product-big-title").find("span.atver").attr('unit');
                if(unit == 'ream'){
                    if($(this).hasClass("paper_spec")){
                        $("#defindHtml").children("div").find("input#reamSizeId").attr("specvalueid",$(this).attr('specvalueid'));
                    }else{
                        $("#defindHtml").children("div").find("input#reamChooseId").attr("specvalueid",$(this).attr('specvalueid'));
                    }
                }else{
                    if($(this).hasClass("paper_spec")){
                        $("#defindHtml").children("div").find("input#tonSizeId").attr("specvalueid",$(this).attr('specvalueid'));
                    }else{
                        $("#defindHtml").children("div").find("input#tonChooseId").attr("specvalueid",$(this).attr('specvalueid'));
                    }
                }
            }
//判断是否设计商品加急
            if($(this).hasClass("designUrgent")){ //如果不加急，
                $("span.totalPrice").find("strong").text( parseFloat($("span.totalPrice").find("strong").text()) - parseFloat($("#quickPrice").text()));
                $("#quickPrice").text('0.0');
                $("input#designUrgentVal").attr("specvalueid",$(this).attr("specvalueid"));
                return;
            }else if($(this).hasClass("designQuick")){
                $("#quickPrice").text($(this).attr("price"));
                $("span.totalPrice").find("strong").text(parseFloat($("span.totalPrice").find("strong").text()) + parseFloat($(this).attr('price')));
                $("input#designUrgentVal").attr("specvalueid",$(this).attr("specvalueid"));
                return;
            }


        }else{
            var flag = true;
            //如果有选中且要取消时，判断 是否是最后一个normal
            if($(this).hasClass("normal")){
            $("span.partParam").each(function () {
               if($(this).children(".AttributeOptionDto:visible").find("span.normal.atver").length<2){
                        flag = false ;
               }
            });
            }
            if(!flag){
                return;
            }

                if((!$(this).hasClass('must') || !$(this).hasClass("normal")) && !$(this).hasClass('paper_spec') && !$(this).hasClass("exclud")){
                    $(this).removeClass('atver');
                }
                //如果是设计产品
                // if($(this).hasClass('design')){
                //     $(".designHtml").hide();
                // }
        }

        //判断如果有大纸尺寸参数，需要页面变化参数

        if($(this).hasClass('paper_spec')){
            var obj = $(this);
            var optionWid = $(this).attr('optionWid');
            var optionLen = $(this).attr('optionLen');
            obj.parents("li").siblings("li.product-big-unusual").find("input").each(function (i,o) {
                if(!obj.attr('very')&&i==0){
                    $(o).prop('readonly',true);
                    $(o).val(optionWid);
                }else if(!obj.attr('very')&&i==1){
                    $(o).prop('readonly',true);
                    $(o).val(optionLen);
                }else{
                    $(o).removeAttr('readonly');
                    $(o).val(optionWid);
                    $(".hidInput").val(null);
                }
            })
        }

        if($(this).attr('very')){ //如果是特规 则不返回
            return;
        }

        installParam();
    }
});


//页面sku组装array;
function attributeOptionNames() {
    var goodsType = $("#goodsType").val();
    var partAndAttrRelateOptListMap = {};

    $("span.partParam").each(function () {
        var attributeOptionNames = [];
        $(this).find(".AttributeOptionDto:visible").each(function () {
            var obj = $(this);
            $(this).find("span.spec-attr").each(function () {
                    var attributeKey = obj.find("span[optionId]").attr('attributeKey');
                if($(this).hasClass("atver") || ($("span.the_custom[attributevaluetype=size]").hasClass("atv") && attributeKey == 'size')){

                    if(goodsType == "material" && attributeKey == 'size' ){
                        var str = $(this).attr('optionvalue').substr(2,$(this).attr('optionvalue').length-4).replace(/\"/g,'').split(",");
                        $("#materialLength").val(str[0]);
                        $("#materialWidth").val(str[1]);
                    }
                        var attrOpt = {};
                    if(goodsType == "material" && $("span.the_custom[attributevaluetype=size]").hasClass("atv") && attributeKey=='size'){
                        attrOpt['optionId'] = -1;
                    }else{
                        attrOpt['optionId'] = $(this).attr('specvalueid');
                    }
                        var squre = {};
                        squre['id'] = obj.find("span[optionId]").attr('optionId');
                        squre['attributeType'] = obj.find("span[optionId]").attr('attributeType');
                        squre['attributeKey'] = obj.find("span[optionId]").attr('attributeKey');
                        squre['influenceCraftPriceType'] = obj.find("span[optionId]").attr('influenceCraftPriceType');
                        squre['joinBuildSku'] = obj.find("span[optionId]").attr('joinBuildSku');

                        attrOpt['squareVO'] = squre;
                        attributeOptionNames.push(attrOpt);

                }
            });
        });
        var partId = $(this).attr("partId");
        partAndAttrRelateOptListMap[partId] = attributeOptionNames;

    })
    return partAndAttrRelateOptListMap;
}

//设计商品弹出框
function designSendParam(){
    var res = template("designHtml",$.parseJSON($("#designData").val()));
        $.prompt({
            style: 'width:900px;left:450px',
            title: '选择设计服务',
            con: res,
        });
}

//点击设计服务类型
$(document).on('click',".product-spec-price-box-design",function () {
    $(this).addClass("atver").siblings().removeClass("atver");

    //设计ajax
    sendDesignAjax($(this));
});

function sendDesignAjax(obj){
    var partAndAttrRelateOptListMap = {};

    //$("span.Nourgent").addClass('atver').siblings().removeClass('atver');

    var attributeOptionNames = [];
    var attrOpt = {};
    attrOpt['optionId'] = obj.attr('specvalueid');
    var squre = {};
    squre['id'] = $("#designSpan").attr('optionId');
    squre['attributeType'] =  $("#designSpan").attr('attributeType');
    squre['attributeKey'] =  $("#designSpan").attr('attributeKey');
    squre['influenceCraftPriceType'] =  $("#designSpan").attr('influenceCraftPriceType');
    squre['joinBuildSku'] =  $("#designSpan").attr('joinBuildSku');

    attrOpt['squareVO'] = squre;
    attributeOptionNames.push(attrOpt);
    var partId = $("span.partParam").attr("partId");
    partAndAttrRelateOptListMap[partId] = attributeOptionNames;

    var goodsParamsVO = {};
    $("input[type=hidden].parameter").each(function () {
        var name = $(this).attr('id');
        var value = $(this).val();
        if(name=='spuId'){
            goodsParamsVO['goodsId'] = value;
        }else{
            goodsParamsVO[name] = value;
        }
    });
    goodsParamsVO['quantity'] = $("#designNum").val();//组装数量


    goodsParamsVO['partAndAttrRelateOptListMap'] = partAndAttrRelateOptListMap;
    var url = "/goods/getSellPrice.json";
    var paramsVO = JSON.stringify(goodsParamsVO);
    var list = JSON.stringify(partAndAttrRelateOptListMap);

    doAjax(url,'post',{"goodsParamsVO":paramsVO},function (ret) {
        if(ret.code=='1'){
            var html = ret.data.basePriceDetail.totalPrice;
            $(".red_price").find(".design_cost").text(html);
            //得到返回的sku
            $("input#designSku").val(ret.data.basePriceDetail.productId);

            $(".urgent_button").attr("urgent",html/2); //加急的费用
            $(".red_price").find(".urgent").text( $("div.urgent_box").find("span.atver").attr("urgent"));
            $(".red_price").find(".total_num").text(parseFloat(html)+parseFloat($(".red_price").find(".urgent").text()));

        }else{
            $.alert("error",ret.message,1);
        }
    });
}


//商品 加 购物车 或立即购买
$(document).on('click','.action-addtocart',function () {

    if($(this).hasClass("nosale")){
        return;
    }
    var addCartDto = {};
    var designDto = [];
    var goodsType = $('#goodsType').val();

    var productId = $("#id").val();
    if(!productId){
        $.alert("error","请参数选择完整",1);
        return;
    }else{
        var check = true;
        $(".partParam").find(".AttributeOptionDto").each(function () {
            if($(this).children("span.item-label").attr("attributetype") == 'normal'){
                if($(this).find("span.normal.atver").length<1 && $(this).children("span.item-label").attr("attributekey")!='size'){
                    check = false
                }else if($(this).children("span.item-label").attr("attributekey")=='size' && $("#materialHtml").attr('flag') == 0 && $(this).find("span.normal.atver").length<1){
                    check = false
                }
            }

        });
        if(!check){
            $.alert("error","请参数选择完整",1);
            return;
        }
    }

    $("input[type=hidden].parameter").each(function () {
        var name = $(this).attr('id');
        var value = $(this).val();
        addCartDto[name] = value;
        // if(name!='id' && name!='spuId'){
        // }else if(name == 'spuId'){
        //     addCartDto['id'] = value;
        // }
    });
    addCartDto['quantity'] = $("input.action-quantity-input").val();//组装数量
    var type = $(this).attr("id");
    if(type=='addcart'){
        addCartDto['operateType'] = 'addcart';
    }else{
        addCartDto['operateType'] = 'buynow';
    }

    if(goodsType == 'paper'){
        var flag = true;
        $("input.drules:visible").each(function () {
            if( $(this).val() == '' ){
                flag = false;
            }
        });
        if(!flag){
            $.alert("error","参数请填写完整",1);
            return ;
        }


        var width = $(".width:visible").val();
        var length = $(".length:visible").val();
        if(!length){
            length = null;
        }
        addCartDto['paperWidth'] = width;
        addCartDto['paperLength'] = length;
        addCartDto['priceUnit'] = $(".product-big-title").find(".paper.atver").attr('unit');

    }else if(goodsType == 'material'){

        var f = true;
        $("input.zdy:visible").each(function () {
            if( $(this).val() == '' ){
                f = false;
            }
        });
        if(!f){
            $.alert("error","自定义尺寸请填写完整",1);
            return ;
        }

        if($("#materialHtml").attr("flag") == 1){ //说明自定义
            addCartDto['paperLength'] = $("input.zdy:visible").eq(0).val();
            addCartDto['paperWidth'] = $("input.zdy:visible").eq(1).val();

        }else{
        var optionValue =  $("span.spec-attr.atver[attributekey=size]").attr('optionvalue');
        var str = optionValue.substr(2,optionValue.length-4).replace(/\"/g,'').split(",");
        addCartDto['paperLength'] = str[0];
        addCartDto['paperWidth'] = str[1];
        }
    }
    //工艺参数数组
    var craftIdList = [];
    $("span.craft").each(function () {
        if($(this).hasClass("atver")){
            craftIdList.push($(this).attr('specvalueid'));
        }
    });
    addCartDto['craftIdList'] = craftIdList;

    //判断附件input#append
    if( $("input#append").val()){
    var  appendIds =  $("input#append").val().substr(0, $("input#append").val().length-1).split(",");
        addCartDto['appendIds'] = appendIds;
    }


    //var attributeOptionName = attributeOptionNames();

    //判断是否有设计商品 如果有 组装参数
    var designLen = $("div.product-buy").find("div.designDto").length;

    if(designLen >=1 && $("#designParam").attr('trussskuid')){  //组装
        var trussDtoList = [];
        var TrussDto = {};
            TrussDto['trussSkuId'] = $("#designParam").attr('trussskuid');
            TrussDto['trussNum'] = $("#designParam").attr('trussNum');
            TrussDto['goodsType'] = $("#designParam").attr('goodsType');
            TrussDto['urgent'] = $("#designParam").attr('urgent');
            TrussDto['designDesc'] = $("#designParam").attr('designDesc');
        trussDtoList.push(TrussDto);

        addCartDto['trussDtoList'] = trussDtoList;
    }

    if(goodsType == 'design'){
        if( !$("#designDesc").val()){
            $.alert("error","请填写需求描述",1);
            return;
        }
        addCartDto['designDesc'] = $("#designDesc").val();
        addCartDto['urgent'] = $("span.exclud.atver").attr('specvalueid') == -9 ? true:false ;

    }
   // addCartDto['partAndAttrRelateOptListMap'] = attributeOptionName;

    //判断是否够库存，是否可以超库存销售
    var store = $("#store").val();//库存
    var isNoStoreSell = $("#isNoStoreSell").val();//是否支持超

    if(addCartDto['quantity']>store){
        if(!isNoStoreSell){
            $.alert("error","所选商品超过库存",1);
            return;
        }
    }
    if(type=='addcart'){ //添加购物车
        doAjax("/cart/productAddCart","post",{"addCartDto":JSON.stringify(addCartDto)},function (ret) {
            if(ret.code == 1){
            $.alert("success","添加购物车成功",1);
            }else{
            $.alert("error",ret.message,1);
            }
        })
    }else{
    	 if($(this).hasClass('alreadyClicked')){
			 return;
		 }
    	$(this).addClass('alreadyClicked');
        doAjax("/order/popGoDown/bzRedirectIndex.json","post",{"addCartDto":JSON.stringify(addCartDto)},function (ret) {
        	if(ret.code=="200"){
               var url="/order/popGoDown/index.do";
               location.href = url;
           }else{
        	   //返回错误页面
        	   alert()
           }
        })
    }

});

//地址
$(".address_text").hover(function(){
    $(".address_select").show();
    if($(".address_tab span").index('.atver')!=-1)
    {
        $(".address_con").eq(0).show();
    }


},function(){

    $(".address_select").hide();
    $(".address_con").hide().eq(1).show();
    $(".address_tab i").eq(2).text('请选择').hide();
    $(".address_tab span").removeClass('atver').eq(1).addClass('atver');
})
$(".address_tab span").each(function(i, o) {
    $(o).click(function(){
        $(o).addClass('atver').siblings().removeClass('atver');
        $(".address_con").hide().eq(i).show();
    })
});
$.select_add('address_op',region_Data,1323);//默认湖北武汉江汉区
$(".address_con").each(function(i, o) {
    $(o).html($(".address_op").eq(i).html());
    $(o).find("option").each(function(index, element) {
        $(element).wrapAll(document.createElement("span"));
    });
    $(o).on('click','option',function(){
        $(".address_op").eq(i).val($(this).attr('value'))
        $(".address_tab span").eq(i).find('i').text($(this).text());
        var id=$(this).attr('value')
        add_div(region_Data,id,i);
    })
});

function add_div(jsonData,id,index)
{
    getJsonLength=function(jsonData)
    {
        var jsonLength = 1;
        for(var item in jsonData){
            jsonLength++;
        }
        return jsonLength;

    };

    var len=getJsonLength(region_Data);

    if(index==0)
    {
        $(".address_con").eq(1).html('');
        $(".address_con").eq(2).html('');
        $(".address_tab i").eq(1).text('请选择');
        $(".address_tab i").eq(2).text('请选择').hide();
        //for(var i=1;i<len;i++)
        for ( i in jsonData)
        {
            if(jsonData[i]!=undefined && jsonData[i]['p_region_id']==id)
            {
                $(".address_con").eq(1).append("<option value="+jsonData[i]["region_id"]+">"+jsonData[i]["local_name"]+"</option>");

            }
        }
        $(".address_con").eq(1).find("option").each(function(index, element) {
            $(element).wrapAll(document.createElement("span"));
        });
        $(".address_tab span").removeClass("atver").eq(1).addClass("atver");
        $(".address_con").hide().eq(1).show();

    }
    if(index==1)
    {
        $(".address_con").eq(2).html('');
        $(".address_tab i").eq(2).text('请选择').show();
        //for(var i=1;i<len;i++)
        for ( i in jsonData)
        {
            if(jsonData[i]!=undefined && jsonData[i]['p_region_id']==id)
            {
                $(".address_con").eq(2).append("<option value="+jsonData[i]["region_id"]+">"+jsonData[i]["local_name"]+"</option>")

            }
        }
        $(".address_con").eq(2).find("option").each(function(index, element) {
            $(element).wrapAll(document.createElement("span"));
        });
        if($(".address_con").eq(2).text()=='')
        {
            $(".address_tab span").eq(2).hide().html('<i></i>');
            $(".address_text a").text($(".address_tab").text());
            $(".address_select").hide();
            $(".input_addr").val(id);

            installParam();

        }
        else
        {
            $(".address_tab span").eq(2).show().html('<i>请选择</i>');

        }
        $(".address_tab span").removeClass("atver").eq(2).addClass("atver");
        $(".address_con").hide().eq(2).show();
    }
    if(index==2)
    {
        $(".address_text a").text($(".address_tab").text());
        $(".address_select").hide();
        $(".input_addr").val(id);

        installParam();

        // doAjax('http://www.11ziyun.com/goods/getFreightprice','post',{'areaId':id,'productId':$('.productID').val(),'count':$('.action-quantity-input').val()},function(params){
        //     $('.areaId').val(id);
        //     $('.freightPrice').text('￥'+params['data']);
        // })
    }
}

$(function(){

    //相册
        $(document).ready(function () {
        $.zy_scroll('.thumbnail-list','.flip_prev','.flip_next','.thumbnail-list',4,false);
        })
        $(document).on('click',".thumbnail-list ul li",function () {
        $(this).addClass('atver').siblings().removeClass('atver');
        $('.product-album-preview').find("img").attr("src",$(this).find("img").attr("src")).css("opacity",0).stop().animate({opacity:1});
        });

//     //收藏
//     $(document).on('click','.addfav',function(){
//         var redirect_url = 'http://www.11ziyun.com/login';
//         if(redirect_url=='1'){
//             if($('.addfav i').attr("value")=='1'){
// //                $.alert('error', '商品已收藏',1);return;
//                 var goodsId = $('.goodsID').val();
//                 $(this).find('i').removeClass('atver');
//                 doAjax('http://www.11ziyun.com/member/del-collect-goods','post',{'goodsId':goodsId},function(data){
//                     if(data['result']=='1'){
//                         $('.addfav i').attr('value',0)
//                         $.alert('success', '取消成功');return;
//                     }else{
//                         $.alert('error', '取消失败');return;
//                     }
//                 })
//             }else{
//                 var info = {};
//                 info['goodsIds'] = $('.goodsID').val();
//                 $(this).find('i').addClass('atver')
//                 doAjax('http://www.11ziyun.com/member/do-collect-goods','post',info,function(data){
//                     if(data['result']=='1'){
//                         $('.addfav i').attr('value',1)
//                         $.alert('success', '收藏成功');return;
//                     }else{
//                         $.alert('error', '收藏失败');return;
//                     }
//                 })
//             }
//         }
//         else{
//             window.location.href=redirect_url;return;
//         }
//     })



    //减少数量
    $(document).on('click','.btn-decrease',function(){
        var pic_buy='';
        var input_obj = $(".action-quantity-input");
        var cur_val = Number(input_obj.val());
        if(cur_val  <=1 )return;
        CountAnim(this,cur_val+'',(cur_val-1)+'',-40);
        if($('.product-big-title span.atver').attr('unit')=='ream')
        {
        input_obj.val(Number(cur_val-1).toFixed(3));
        }
        else if($('.product-big-title span.atver').attr('unit')=='ton')
        {
        input_obj.val(Number(cur_val-1).toFixed(6));
        }
        else
        {
        input_obj.val(Number(cur_val-1));
        }

        num_data(pic_buy,input_obj.val())
//            if($('.addcartBuyType').val()=='design_service'){
//                $(".total_num").text(Number($(".select-design_cost").text())+Number($(".select-design_urgent").text()))
//            }else{
//                $(".total_num").text(Number($(".design_cost").text())+Number($(".urgent").text()))
//            }
    });

    //增加数量
    $(document).on('click','.btn-increase',function(){
        var pic_buy = '';
        var input_obj = $(".action-quantity-input");
        var cur_val = Number(input_obj.val());
        var store = Number($('#store').val());
        if(cur_val  >=9999)return;
        CountAnim(this,cur_val+'',(cur_val+1)+'',-40);
        if($('.product-big-title span.atver').attr('unit')=='ream')
        {
        input_obj.val(Number(cur_val+1).toFixed(3));
        }
        else if($('.product-big-title span.atver').attr('unit')=='ton')
        {
            input_obj.val(Number(cur_val+1).toFixed(6));
        }
        else
        {
        input_obj.val(Number(cur_val+1));
        }

        num_data(pic_buy,input_obj.val());
    });

    $(document).on('change','.action-quantity-input',function(){

        var pic_buy='';
        var minBuy = $(this).attr('minBuy');
        var num = $(this).val();
        if(isNaN(num)){
            $(this).val(minBuy == 0 ? 1 : minBuy);return;
        }else if(num<=0){
            $(this).val(minBuy == 0 ? 1 : minBuy);
            num = minBuy == 0 ? 1 : minBuy;
        }else if(num>9999){
            num = 9999;
        }


        if($("#goodsType").val() != 'paper'){
            $(this).val(Math.ceil(num));
        }
        if($('.product-big-title span.atver').attr('unit')=='ream')
        {
            num = Number(num).toFixed(3);
        }
        else if($('.product-big-title span.atver').attr('unit')=='ton')
        {
            num = Number(num).toFixed(6);
        }
        else
        {
            num = Number(num).toFixed(0);
        }
        num_data(pic_buy,num)
    })
    //数量加减计算
    function num_data(pic,num,dis)
    {
        var goodsType =$('#goodsType').val();
        var info = {};
        if(num>=99999){
            num = 99999;
        }
    //将设计商品加急设计默认
        //$("input#designUrgentVal").attr("specvalueid",$("span.exclud.atver").attr("specvalueid"));

        installParam();//组装参数
    }

    var CountAnim=function(obj,j,l,num){
        var txtCount = $('.action-quantity-input');
        var p=$(obj).parents('.input_box');
        var k='';
        var j=j.split('');
        txtCount.css('color','#fff');
        for (var s = 0; s < j.length; s++)
        {
            k += '<i style="position:relative;">' + j[s] + "</i>";
        }
        p.prepend('<i class="upspan" >' + k + "</i>");

        var m='';
        var l=l.split('');
        for (var n = 0; n <l.length; n++)
        {
            m += '<i style="position:relative;">' + l[n] + '</i>';

        }
        p.append('<i class="downspan" style="top:'+(-num)+'px;">' + m + "</i>");
        var d = $(".downspan i:last");
        var u= $(".upspan i:last");

        u.animate({top: num}, "10");
        d.animate({top: num}, "10",function(){
            $('.downspan,.upspan').remove();
            txtCount.css('color','#333');
        });
    }

})

</script>

<script type="text/html" id="designHtml">
    <div class="product-design">
        <input type="hidden" id="designSku" value="">
        <div class="product-spec-price-shipping product-buy" style="width: inherit;">
            <div class="product-spec-price-box">
                <span style="display: none" id="designSpan" optionId="{{attrSquare['id']}}" attributeType="{{attrSquare['attributeType']}}" attributeKey="{{attrSquare['attributeKey']}}" influenceCraftPriceType="{{attrSquare['influenceCraftPriceType']}}"></span>
                {{each optionDTO option}}
                <div class="product-spec-price-box-design spec-price-box-design design" design_cost="" text="{{option['squareName']}}" specvalueid="{{option['id']}}" >
                <div class="product-box-design-title">{{option['squareName']}}<span id="{{option['id']}}"></span></div>
                <div class="product-box-design-con">
                </div>
            </div>
            {{/each}}
        </div>

        <div class="product-spec-price-box">
            <span class="item-label">加急</span>
            <div class="item-content urgent_box">
                  <span class="spec-attr group atver" urgent='0.00' text='不加急'>
                      不加急
                      <em></em>
                  </span>
                <span class="spec-attr group urgent_button " urgent='0.00' text='加急'>
                      加急
                      <em></em>
                  </span>
                <span  style=" margin:0px 5px; float: right;"><t style="display:inline-block; width:15px; height:15px; border-radius:100%; background:#b5b5bd;vertical-align: text-bottom; text-align:center; line-height:15px; color:#FFFFFF; margin-right:5px;">?</t>加急服务：初稿时间快50%，需加收50%点加急费</span>
            </div>
        </div>

            <div class="product-spec-price-box">
                <span class="item-label">数量</span>
                <div class="item-content">
                    <em class="input_box">
                        <a href="javascript:void(0);" class="increase">+</a>
                        <input onkeydown="if(event.keyCode==13)return false;" type="text" id="designNum" name="goods[num]" class="quantity-input action-quantity-input" value="1" min="1" max="9999">
                        <a href="javascript:void(0);" class="decrease">-</a>
                    </em>
                </div>
            </div>

        <div class="product-spec-price-box">
            <span class="item-label">需求描述</span>
            <div class="item-content">
                <textarea placeholder="需求描述" class="describe" maxlength="240"></textarea>
            </div>
        </div>
        <div class="product-spec-price-box" style="line-height:30px; background:#f1f1f1;">
            <span class="item-label">设计费用</span>
            <span class="red_price"><strong class="design_cost">0.00</strong></span>
            <span class="item-label">加急费用</span>
            <span class="red_price"><strong class="urgent">0.00</strong></span>
            <span class="item-label"><strong>总金额</strong></span>
            <span class="red_price"><strong class="total_num">0.00</strong></span>
        </div>
        <div class="product-spec-price-box" style="line-height:30px; text-align:center; margin-top:15px;">
            <button class="design-but">确定</button>
        </div>
    </div>
    </div>

</script>

<script>


    $(document).on('click',"span.group",function () {
        if($(this).hasClass("atver")){
            return
        }else{
            $(this).addClass("atver").siblings().removeClass("atver");
            //得到当前的加急费用设置过去
            var urgentPrice = $(this).attr("urgent");
            $(".red_price").find(".urgent").text( $("div.urgent_box").find("span.atver").attr("urgent"));

            $(".red_price").find(".total_num").text(parseFloat($(".red_price").find(".design_cost").text())+parseFloat($(".red_price").find(".urgent").text()));
        }
    });

    //减少数量
    $(document).on('click','.decrease',function(){
        var num = Number($("#designNum").val())-1;
        var pic_buy=$('.product-spec-price-box-design.atver').length;
        if(!pic_buy){
            $.alert('error', '请选择相关设计~');return;
        }
        if(num  >999 )return;
        if(num  <1 )return;
        CountAnim(this,(num)+'',(num)+'',-40);
        $("#designNum").val(num);
        sendDesignAjax($(".product-spec-price-box-design.atver"));
    });

    //增加数量
    $(document).on('click','.increase',function(){
        var num = Number($("#designNum").val())+1;
        var pic_buy=$('.product-spec-price-box-design.atver').length;
        if(!pic_buy){
            $.alert('error', '请选择相关设计~');return;
        }
        if(num  >999 )return;
        CountAnim(this,(num)+'',(num)+'',-40);
        $("#designNum").val(num);
        sendDesignAjax($(".product-spec-price-box-design.atver"));

    });
    //手动输入数量
    $(document).on('change','#designNum',function(){
        var num = Number($("#designNum").val());
        var minBuy = $(this).attr("min");
        if(isNaN(num)){
            $(this).val(minBuy == 0 ? 1 : minBuy);return;
        }else if(num<=0){
            $(this).val(minBuy == 0 ? 1 : minBuy);
            num = minBuy == 0 ? 1 : minBuy;
        }

        var pic_buy=$('.product-spec-price-box-design.atver').length;
        if(!pic_buy){
            $.alert('error', '请选择相关设计~');return;
        }

        if(num  >999 ){
            $(this).val(999);
        }


        sendDesignAjax($(".product-spec-price-box-design.atver"));
    });

    $(document).on('click',".popup-btn-close",function(){
        if(!$('.product-spec-price-box-design.atver').length && !$("#designParam").attr("trussSkuId")){
        $("span.design[specvalueid=0]").addClass("atver").siblings().removeClass("atver");
        }

        if($(".design_id").val()=="")
        {
            $("div#defindHtml").find("div#designAppendHtml").html('');
//			$(".spec-attr-design").removeClass("atver").eq(0).addClass("atver")
            $('.select-design_cost').html('0.00');
            $('.select-design_urgent').html('0.00');
            $(".total_num").text('0.00');
            return false
        }
    });

    //点击确定
    $(document).on("click",'.design-but',function () {
        setTimeout(function(){
            var pic_buy=$('.product-spec-price-box-design.atver').length;
            if(!pic_buy){
                $.alert('error', '请选择相关设计~');return;
            }else{
                if(!$(".describe").text()){
                    $.alert('error', '请填写需求描述');return;
                }

                var designHtml =  $('.product-spec-price-box-design.atver').attr("text")+"+"+$("div.urgent_box").find("span.atver").attr('text')+"(￥"+ $(".total_num").text()+")";
                var html = " <span style='margin-left: 19.5%;border: 1px solid #ff5e4c;padding: 2px 15px;position: relative;margin-bottom: 10px;min-width: 62px;text-align: center; height: 28px; line-height: 28px;color: #666666;overflow: hidden; class='cont' specvalueid='-7'>"+designHtml+"</span>";
                $("div#defindHtml").find("div#designAppendHtml").html(html);//将自定义的元素保存
                $("span.design[specvalueid=1]").next().remove();
                $("span.design[specvalueid=1]").after(html);
                $("#designParam").attr("trussSkuId",$("input#designSku").val());
                var urgent = $("div.urgent_box").find("span.atver").hasClass("urgent_button");
                $("#designParam").attr("urgent",urgent);
                $("#designParam").attr("trussNum",1);
                $("#designParam").attr("designDesc",$(".describe").text());
                $(".popup-btn-close").click();

            }
        },500)
    });

    var CountAnim=function(obj,j,l,num){
        var txtCount = $('#designNum');
        var p=$(obj).parents('.input_box');
        var k='';
        var j=j.split('');
        txtCount.css('color','#fff');
        for (var s = 0; s < j.length; s++)
        {
            k += '<i style="position:relative;">' + j[s] + "</i>";
        }
        p.prepend('<i class="upspan" >' + k + "</i>");

        var m='';
        var l=l.split('');
        for (var n = 0; n <l.length; n++)
        {
            m += '<i style="position:relative;">' + l[n] + '</i>';

        }
        p.append('<i class="downspan" style="top:'+(-num)+'px;">' + m + "</i>");
        var d = $(".downspan i:last");
        var u= $(".upspan i:last");

        u.animate({top: num}, "10");
        d.animate({top: num}, "10",function(){
            $('.downspan,.upspan').remove();
            txtCount.css('color','#333');
        });
        // alert(l);
        // $('#designNum').val(l);
    }

</script>

<script>
    //商品上传附件
    var fileIdList="";
    var i = 0;
        $.files_up_oss({
            id:['uploadFile'],//按钮id
            url: "/oss/getSignatureNew",
            dir: "order/orderImage/",
            file_type: "jpg,png,gif,psd,ai,cdr,eps,ppt,word,excel,pdf,tiff,rar,zip,7z,gif",
            size: "100mb",//mb
            view_url: "https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/"
        },function(index_number,json){
            if (json.Status == 'OK') {
                    i++;
                    $("#fileNum").val(json.total);
                var requestData={
                    url:json.filename,
                    name:json.filename,
                    size:json.size,
                    type:json.mimeType,
                    uniqueId:(new Date()).valueOf()
                }

                doAjax("/user/userAccessory/addAccessory.json", 'post', {'requestData':JSON.stringify(requestData)}, function(ret){
                    var fileId=ret.data.resultDtos[0].id;
                    $("input#append").val( $("input#append").val()+fileId+",");
                    var html = "<em class='fileEm'>\n" +
                        " <a href=\"javascript:\" style=\"text-decoration:none;color: #6647b2;display: inline-block;width: 100px;height:34px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;vertical-align: top;\">"+json.filename+"</a>\n" +
                        "  <i class=\"del\" style=\"margin-top: 5px;;display: inline-block;width: 15px;height: 15px;cursor: pointer; margin-left: 15px; color: #f16c6c; line-height: 15px;text-align: center;\" aid="+fileId+">X</i>\n" +
                        " </em>"
                     $(".picture").append(html);
                });
            }
            if(json.total>1){
                $("span.moreFile").show();
            }
        });


    //删除附件
        $(document).on('click',"i.del",function () {
            var aid = $(this).attr('aid');
            $(this).parent().remove();
            if($("em.fileEm").length<2){
                $("span.moreFile").hide();
            }
            var appendArr =  $("input#append").val().substr(0, $("input#append").val().length-1).split(",");
            appendArr.splice($.inArray(aid,appendArr),1);//剔除当前元素
            if(appendArr.length == 0){
                $("input#append").val('');
            }else{
                $("input#append").val(appendArr.toString()+",");
            }
        });

        var flag = true;
        $(document).on("click","span.moreFile",function () {
            if(flag){
                flag = false;
            $("span.picture").css("height","auto");
            }else{
                flag = true;
            $("span.picture").css("height","30px");
            }
        });

        $(document).on("click","div.product-attributes>span",function () {
            $(this).addClass("atver").siblings().removeClass("atver");
            $("#"+$(this).attr("name")).show().siblings("div").hide();
        })


</script>



<script>

    $(document).on("change","p input.zdy",function () {
        var v1 = $(this).val();
        var attributevaluetype = $(this).attr("attributevaluetype");
        if( isNaN(v1) || parseFloat(v1)<=0 || -1 !== v1.indexOf('-') ){
            $.alert("error","数据填写不合法",0.5);
            $(this).val('');
            return;
        }

        var max = $(this).attr('max');
        var min = $(this).attr('min');
        if(max=='' || min==''){
            $.alert("error","自定义长度配置错误",0);
            return;
        }
        if( parseFloat(min) > parseFloat(v1) || parseFloat(max) < parseFloat(v1) ){
            $.alert("error","数据填超出合法范围",0);
            $(this).val('');
            return;
        }

        $(this).attr('value',v1);
        if($(this).val()){   //如果自己变化的有值
            if($(this).siblings("input").length){
                var inputNum = 0;
                $(this).siblings("input").each(function () {
                    if($(this).val()){
                        inputNum++;
                    }
                });
                if(inputNum == $(this).siblings("input").length){
                    $("#materialHtml").html($(this).parent().html());
                    $("#materialHtml").attr('attributevaluetype',attributevaluetype);
                    installParam();
                }
            }else{
                $("#materialHtml").html($(this).parent().html());
                $("#materialHtml").attr('attributevaluetype',attributevaluetype);
                installParam();
            }
        }

    })

    $(document).on('click',".the_custom",function () {
        var defLength = $(this).attr('val');
        var attributevaluetype = $(this).attr('attributevaluetype');
        var id = $(this).attr("id");
        if(!$(this).hasClass("atv")){
            $(this).addClass("atv");
        if(defLength){
            var str = defLength.replace(/\[/g,""); str = str.replace(/\]/g,""); var array = str.split(","); var size = array.length/2 >=1 ? 2 : 1;
            array = chunk(array,size);//组装成需要的数组
            var maxmin = array.shift();//删除最前的一个元素，并返回
            var html = "";
            if(array.length==0){
                html += "<input type='text' class='the_custom_ipt last zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributevaluetype="+attributevaluetype+">";
            }else{
                html += "<input type='text'  class='the_custom_ipt zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributevaluetype="+attributevaluetype+" >";
            }
            if(array.length > 0){
                for(var i=0;i<array.length;i++){
                    html+="<img src='https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fimage%2Fzy_img_04.png'> ";
                    if(i == array.length-1){
                        html+="<input type='text' class='the_custom_ipt last zdy' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributevaluetype="+attributevaluetype+" >";
                    }else{
                        html+="<input type='text' class='the_custom_ipt zdy ' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributevaluetype="+attributevaluetype+" >";
                    }
                }
            }
            $("#material_"+id).html(html);
            $("#materialHtml").attr('flag',1);

        }
    }else{
        $(this).removeClass("atv");
            $(this).next("span.defInput").html('');
            $("#materialHtml").html('');
            $("#materialHtml").attr('flag',0);
            $("#materialHtml").attr('attributevaluetype','');
            installParam();
    }
    })


    //切割数组，分组
    function chunk(arr,size){
        var arr1 = [];
        if(size>1){
            for(var i=0;i<arr.length;i=i+size){
                var arr2 =arr;
                arr1.push(arr2.slice(i,i+size));
            }
            return arr1;
        }else{
            arr1.push(arr.slice(0,2));
            return arr1;
        }
    }
</script>
